<template>
	<view class="container">
		<Header>个人年度履职报告</Header>
		<view class="content">
			<view class="title">
				{{data.title}}
			</view>
			<view class="date">
				<span v-if="data.createtime_text">{{data.createtime_text}}</span>
			</view>
			<view v-html="data.content"></view>
			
		</view>
	</view>
</template>

<script>
	import Header from '../../components/header.vue'
	import request from '../../common/request.js'
	export default {
		components: {
			Header
		},
		data() {
			return {
				id: '',
				data:{}
			}
		},
		onLoad(option) {
			this.id  = option.id
		},
		mounted(){
			this.getDetailData()
		},
		methods: {
			getDetailData(){
				request({
					url:'/Lvreport/detail',
					data:{
						report_id: this.id
					},
					method: 'POST'
				}).then(res => {
					if(res.code == 1){
						this.data = res.data
					}else{
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 2000
						});
					}
				})
			},
			dlikecCollect(type){
				request({
					url:'/speak/dlikecCollect',
					data:{
						speak_id: this.id,
						type: type
					},
					method: 'POST'
				}).then(res => {
					if(res.code == 1){
						let msg = ''
						if(type == 1){
							if(this.data.like == 1){
								this.data.like = 0
								msg = '取消点赞'
							}else{
								this.data.like = 1
								msg = '点赞成功'
							}
						}else{
							if(this.data.collect == 1){
								this.data.collect = 0
								msg = '取消收藏'
							}else{
								this.data.collect = 1
								msg = '收藏成功'
							}
						}
						uni.showToast({
							title: msg,
							icon: 'none',
							duration: 2000
						});
					}else{
						uni.showToast({
							title: res.msg,
							icon: 'none',
							duration: 2000
						});
					}
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	
	.content {
		padding: 20px;
		line-height: 30px;
	}

	.title {
		font-size: 16px;
		font-weight: bold;
		text-align: center;
		line-height: 26px;
	}

	.date {
		font-size: 14px;
		text-align: center;
		margin: 10px 0px;
	}
</style>